.TH "LevelTwo" 3 "4 Dec 2009" "Earth: 20000" \" -*- nroff -*-
.ad l
.nh
.SH NAME
LevelTwo \- 
.SH SYNOPSIS
.br
.PP
.PP
\fC#include <levelTwo.h>\fP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBLevelTwo\fP (QGraphicsScene *theScene)"
.br
.in -1c
.SS "Private Member Functions"

.in +1c
.ti -1c
.RI "QRectF \fBboundingRect\fP () const "
.br
.ti -1c
.RI "void \fBpaint\fP (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)"
.br
.ti -1c
.RI "int \fBgenerateRandomNumber\fP (int min, int max)"
.br
.in -1c
.SS "Private Attributes"

.in +1c
.ti -1c
.RI "int \fBxPos\fP"
.br
.ti -1c
.RI "int \fByPos\fP"
.br
.ti -1c
.RI "\fBBlock\fP * \fBblock\fP [9][20]"
.br
.in -1c
.SH "Detailed Description"
.PP 
\fBlevelTwo.cpp\fP
.PP
Creates the design for the second level. Uses the polymorphism feature of the \fBblock.cpp\fP class and randomly generates blocks of different colors and places them in a pre-defined layout.
.PP
This level contains powerups
.PP
Author: Natraj Subramanian 
.PP
Definition at line 19 of file levelTwo.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "LevelTwo::LevelTwo (QGraphicsScene * theScene)"
.PP
Definition at line 4 of file levelTwo.cpp.
.PP
.nf
5 {
6     xPos = -380 + (BOUNDWIDTH - 20 * OUTLINEW)/2;       // 260
7     yPos = -630 + (BOUNDHEIGHT)/(5);
8     int randomPowerBlock, powerupCounter;
9     powerupCounter = 0;
10 
11     // Declare variable to hold seconds in clock
12     time_t seconds;
13 
14     // Get value from system clock and place in seconds variable
15     time(&seconds);
16 
17     // Convert seconds to a unsigned integer
18     srand((unsigned int) seconds);
19 
20     int detColor;
21 
22     for(int i = 0; i < 9; i++)
23     {
24         for(int j = 0; j < 20; j++)
25         {
26             if( (i == 0) && ( j > 6 && j < 13 )||
27                 (i == 1) && ( j == 0 || ( j > 7 && j < 12 )|| j == 19) ||
28                 (i == 2) && ( j == 0 || j == 1 || j == 9 || j == 10 || j == 18 || j == 19) ||
29                 (i == 3) && ( j < 3 || j > 16 ) ||
30                 (i > 4 && i < 9) && (j == 0 || j == 1 || j == 9 || j == 10 || j == 18 || j == 19))
31             {
32                  xPos += BLOCKW + SPACE;
33             }
34             else
35             {
36                 detColor = generateRandomNumber(0,5);
37                 randomPowerBlock = generateRandomNumber(0,1);
38 
39                 if(detColor == 0)
40                 {
41                     block[i][j] = new MonoBlock;
42                 }
43                 if(detColor == 1)
44                 {
45                     block[i][j] = new RedBlock;
46                 }
47 
48                 if(detColor == 2)
49                 {
50                     block[i][j] = new GreenBlock;
51                 }
52                 if(detColor == 3)
53                 {
54                     block[i][j] = new BlueBlock;
55                 }
56                 if(detColor == 4)
57                 {
58                     block[i][j] = new MagentaBlock;
59                 }
60                 if(detColor == 5)
61                 {
62                     block[i][j] = new YellowBlock;
63                 }
64 
65                 // Randomly set the powerup value for the current block
66                 // to either 1 or 2.
67                 if(randomPowerBlock == 1 && powerupCounter < 7)
68                 {
69                     block[i][j]->setPowerup(1);
70                     powerupCounter++;
71 
72                     if(powerupCounter % 3 == 0)
73                     {
74                         block[i][j]->setPowerup(2);
75                     }
76                 }
77 
78                 // setXPos and setYPos are used to assist the ball with its block
79                 // collision detection
80                 block[i][j]->setXPos(xPos);
81                 block[i][j]->setYPos(yPos);
82                 block[i][j]->scale(1.0, 1.0);
83                 block[i][j]->setPos(xPos, yPos);
84                 xPos += BLOCKW + SPACE;
85                 theScene->addItem(block[i][j]);  
86             }
87         }
88 
89         yPos += BLOCKH + SPACE;
90         xPos = -380 + (BOUNDWIDTH - 20 * OUTLINEW)/2;
91     }
92 }
.fi
.SH "Member Function Documentation"
.PP 
.SS "QRectF LevelTwo::boundingRect () const\fC [private]\fP"
.PP
Definition at line 94 of file levelTwo.cpp.
.PP
.nf
95 {
96     return QRectF(375, 625, BOUNDWIDTH, BOUNDHEIGHT);
97 }
.fi
.SS "int LevelTwo::generateRandomNumber (int min, int max)\fC [private]\fP"Given a min and a max, generate a random number between this range 
.PP
Definition at line 110 of file levelTwo.cpp.
.PP
.nf
111 {
112     return rand() % (max - min + 1) + min;
113 }
.fi
.SS "void LevelTwo::paint (QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = \fC0\fP)\fC [private]\fP"
.PP
Definition at line 99 of file levelTwo.cpp.
.PP
.nf
100 {
101     Q_UNUSED(painter);
102     Q_UNUSED(option);
103     Q_UNUSED(widget);
104 }
.fi
.SH "Member Data Documentation"
.PP 
.SS "\fBBlock\fP* \fBLevelTwo::block\fP[9][20]\fC [private]\fP"
.PP
Definition at line 23 of file levelTwo.h.
.SS "int \fBLevelTwo::xPos\fP\fC [private]\fP"
.PP
Definition at line 22 of file levelTwo.h.
.SS "int \fBLevelTwo::yPos\fP\fC [private]\fP"
.PP
Definition at line 22 of file levelTwo.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for Earth: 20000 from the source code.
